package com.ltxtiyu.video.tool;

import com.ltxtiyu.video.common.DataGridParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;

@SuppressWarnings("restriction")
public class Tool {
    private final static Logger logger = LoggerFactory.getLogger(Tool.class);


	public static DataGridParam genDataGridParam(HttpServletRequest request) {
        String page = request.getParameter("page") == null ? "1" : request
                .getParameter("page");
        page = page.equals("0") ? "1" : page;
//        String pageNum = request.getParameter("pageNum") == null ? "10"
//                : request.getParameter("pageNum");
        String pageNum = request.getParameter("pageNum") == null ? "10"
              : "10";
        String sort = request.getParameter("sort") == null ? "id" : request
                .getParameter("sort");
        String order = request.getParameter("order") == null ? "desc" : request
                .getParameter("order");
        DataGridParam dgp = new DataGridParam();
        dgp.setPage(Integer.parseInt(page));
        dgp.setRows(Integer.parseInt(pageNum));
        dgp.setSort(sort);
        dgp.setOrder(order);
        return dgp;
    }

}
